package ferp.android.tasks.local;

import android.os.AsyncTask;
import ferp.android.activities.Ferp;
import ferp.android.services.IResolverService2;
import ferp.android.services.ServiceException;
import ferp.android.services.ServiceProxy;

/**
 * User: olegs
 * Date: 2/6/13 5:23 PM
 */
public class TaskPreallocator extends AsyncTask<Void, Void, ServiceException>
{
  public TaskPreallocator(Ferp ferp, IResolverService2 service)
  {
    this.ferp    = ferp;
    this.service = service;
  }

  @Override
  protected ServiceException doInBackground(Void... voids)
  {
    try
    {
      ServiceProxy.preallocate(service);

      return null;
    }
    catch (ServiceException e)
    {
      return e;
    }
  }

  @Override
  protected void onPostExecute(ServiceException e)
  {
    if (e != null)
      ferp.exit(e);
  }

  private final Ferp ferp;
  private final IResolverService2 service;
}
